


# SUBDIRS := CoreModule Loader
SUBDIRS := $(wildcard */)
MAKE_DIR := $(MAKE_DIR)

CURRENT_DIR := $(shell pwd)/$(MAKE_DIR)
BUILD_DIR := $(BUILD_DIR)

all:
	@echo Input Nothing

build_file:
	@echo $(BUILD_DIR)
	$(MAKE) -C $(BUILD_DIR) build


clear_file:
	@echo $(BUILD_DIR)
	$(MAKE) -C $(BUILD_DIR) clear


# build 单一目录
build_dir:
#	@echo $(MAKE_DIR)
#	@echo $(CURRENT_DIR)
	@if [ -e $(MAKE_DIR)/Makefile ]; then $(MAKE) build_file BUILD_DIR=$(MAKE_DIR) ; fi
#	$(MAKE) -C $(MAKE_DIR) build

# 清理单一目录
clear_dir:
#	@echo $(MAKE_DIR)
#	@echo $(CURRENT_DIR)
	@if [ -e $(MAKE_DIR)/Makefile ]; then $(MAKE) clear_file BUILD_DIR=$(MAKE_DIR) ; fi
#	$(MAKE) -C $(MAKE_DIR) clear


build:
#	build 全部，调用所有子目录下的makefile
	for dir in $(SUBDIRS); do $(MAKE) build_dir MAKE_DIR=$$dir ; done


clear:
#	清理
#	for dir in $(SUBDIRS); do $(MAKE) -C $$dir clear; done
	for dir in $(SUBDIRS); do $(MAKE) clear_dir MAKE_DIR=$$dir ; done

pack:
#	打包


common_build:
	$(MAKE) -C Common/ all

common_clear:
	$(MAKE) -C Common/ clear

tray_build:
	@echo tray_build
	$(MAKE) build_dir MAKE_DIR=Tray

tray_clear:
	@echo tray_clear
	$(MAKE) clear_dir MAKE_DIR=Tray

agent_build:
	@echo agent_build
	$(MAKE) build_dir MAKE_DIR=Agent

agent_clear:
	@echo agent_clear
	$(MAKE) clear_dir MAKE_DIR=Agent

driver_build:
	@echo driver_build
	$(MAKE) build_dir MAKE_DIR=Driver

driver_clear:
	@echo driver_clear
	$(MAKE) clear_dir MAKE_DIR=Driver
